# 1）
# class Employee:
#     def __init__(self, name, salary):
#         self.name = name
#         self.salary = salary
#
#     def calculate_pay(self):
#         return self.salary
# 任务1：创建Manager类继承Employee
# 添加bonus属性
# 重写calculate_pay()方法计算总薪资(salary + bonus)
# 任务2：创建HourlyEmployee类继承Employee
# 添加hours_worked属性
# 重写calculate_pay()方法计算时薪(salary * hours_worked)


class Employee:
    def __init__(self, name, salary):
        self.name = name
        self.salary = salary

    def calculate_pay(self):
        return self.salary

class Manager(Employee):
    def __init__(self, name, salary,bonus):
        super().__init__(name,salary)
        self.bonus=bonus
    def calculate_pay(self):
        super().calculate_pay()
        return self.salary+self.bonus

class HourlyEmployee(Employee):
    def __init__(self, name, salary,hours_worked):
        super().__init__(name,salary)
        self.hours_worked=hours_worked
    def calculate_pay(self):
        super().calculate_pay()
        return self.salary*self.hours_worked

dd= Employee('张三',12)
print(dd.calculate_pay())
ddd=Manager('tom',123,1234)
print(ddd.calculate_pay())
dddd=HourlyEmployee('loly',234,23)
print(dddd.calculate_pay())
# 2）设计一个简单的游戏系统，包含不同类型的角色（战士、法师、射手），每个角色都有attack()
# 方法，但实现方式不同。请用代码展示如何利用多态来实现这个系统。
class juese:
    def __init__(self,name):
        self.name=name
    def attack(self):
        return f'欢迎来到王者峡谷,召唤师'

class zhanshi(juese):
    def __init__(self,name,wuqi):
        super().__init__(name)
        self.wuqi=wuqi
    def attack(self):
        return f'战士{self.name}用{self.wuqi}攻击'

class sheshou(juese):
    def __init__(self,name,wuqi):
        super().__init__(name)
        self.wuqi=wuqi
    def attack(self):
        return f'射手{self.name}用{self.wuqi}攻击'

class fashi(juese):
    def __init__(self,name,wuqi):
        super().__init__(name)
        self.wuqi=wuqi
    def attack(self):
        return f'法师{self.name}用{self.wuqi}攻击'

def method(juese): # int str list  shape1代表一个对象
    print("*****",juese.attack())

aa=juese('张三')
bb=zhanshi('凯','刀')
cc=sheshou('后裔','弓箭')
dd=fashi('安琪拉','法典')

print(aa.attack())
print(bb.attack())
print(cc.attack())
print(dd.attack())
method(aa)
method(bb)
method(cc)
method(dd)